package lu.uni.adtool.ui;

import java.awt.BorderLayout;

import javax.swing.JPanel;
import javax.swing.JScrollPane;

import lu.uni.adtool.adtree.ADTreeForGui;

/**
 * A view containing a graphical representation of tree.
 * 
 * @author Piot Kordy
 * @version
 * 
 */
public class ADTreeView extends JPanel
{
  static final long                serialVersionUID = 70266501192502884L;
  private ADTreeForGui tree;
  private ADTreeCanvas canvas;

  /**
   * A defeault constructor.
   * @param newTree new tree
   * @param mainWindow main window of the application
   */
  public ADTreeView(final ADTreeForGui newTree, final MainWindow mainWindow)
  {
    super(new BorderLayout());
    tree = newTree;
    //tree = new ADTreeForGui<ADTreeNode>(new ADTreeNode(
        //ADTreeNode.Type.PROPONENT, Options.tree_defRefType, "Root"));
    canvas = new ADTreeCanvas(tree,mainWindow);
    final JScrollPane scrollPane = new JScrollPane(canvas);
    //scrollPane.setBackground(Options.canv_BackgroundColor);
    //this.setBackground(Options.canv_BackgroundColor);
    //scrollPane.setWheelScrollingEnabled(false);
    scrollPane.setAutoscrolls(true);
    canvas.setScrollPane(scrollPane);
    add(scrollPane);
  }

  /**
   * Constructor.
   * @param newTree a new  Attack Defense Tree.
   */
  //public ADTreeView(final ADTreeForGui newTree)
  //{
    //super(new BorderLayout());
    //tree = newTree;
    //add(new JScrollPane(new ADTreeCanvas(tree)));
  //}

  /**
   * Gets the tree for this instance.
   *
   * @return The tree.
   */
  public final ADTreeForGui getTree()
  {
    return this.tree;
  }

  /**
   * Retuns associated canvas.
   * 
   * @return canvas.
   */
  public final ADTreeCanvas getCanvas()
  {
    return canvas;
  }

}

